package com.antoco.controlcenter.model.video.presenter;

import com.antoco.controlcenter.base.BasePresenter;
import com.antoco.controlcenter.http.observer.HttpRxCallback;
import com.antoco.controlcenter.model.video.biz.OsdBiz;
import com.antoco.controlcenter.model.video.entity.OsdEntity;
import com.antoco.controlcenter.model.video.iface.IOsdView;
import com.trello.rxlifecycle2.LifecycleProvider;

public class OsdPresenter extends BasePresenter<IOsdView, LifecycleProvider> {
    private final String TAG = OsdPresenter.class.getSimpleName();

    public OsdPresenter(IOsdView view, LifecycleProvider activity) {
        super(view, activity);
    }

    /**
     * 登录
     */
    public void startOsdParm(String action, String userName, String pwdword, String title, String presetNum) {

        if (getView() != null)
            getView().showLoading();


        HttpRxCallback httpRxCallback = new HttpRxCallback() {
            @Override
            public void onSuccess(Object... object) {
                if (getView() != null) {
                    getView().closeLoading();
                    getView().showResult((OsdEntity) object[0]);
                }
            }

            @Override
            public void onError(int code, String desc) {
                if (getView() != null) {
                    getView().closeLoading();
                    getView().showToast(desc);
                }
            }

            @Override
            public void onCancel() {
                if (getView() != null) {
                    getView().closeLoading();
                }
            }
        };

        new OsdBiz().startOsdParm(action, userName, pwdword, title, presetNum, getActivity(), httpRxCallback);
    }

}
